<template>
	<view>
		
		<view class="top1-1">
			<view class="top">
				<view class="pres-top-contner">
					<view class="pers-top-userimage">
						<image :src="userData.salt" mode="" class="userimage"></image>
					</view>
					<view class="pers-top-usertext">
						<view class="pers-username">Hi,{{userData.nickName}}</view>
						<view class="pers-usertext">
							<view class="pers-cond">
								<text>祥瑞金融黑钻会员</text>
							</view>
						</view>
					</view>
				</view>
				
				<view class="jifen">
					<text>{{userData.integral}} 积分</text>
					<image class="sanjiao" src="https://z3.ax1x.com/2021/04/29/gkYNFA.png" mode=""></image>
				</view>
			</view>
		</view>
		
		<view class="exclusive-item">
			<view class="item-box">
				<image src="https://z3.ax1x.com/2021/04/29/gkaV6x.png" mode="" class="item-image"></image>
				<view class="item-text">每日签到</view>
			</view>
			<view class="item-box">
				<image src="https://z3.ax1x.com/2021/04/29/gkaApR.png" mode="" class="item-image"></image>
				<view class="item-text">积分兑换</view>
			</view>
			<view class="item-box">
				<image src="https://z3.ax1x.com/2021/04/29/gkatnf.png" mode="" class="item-image"></image>
				<view class="item-text">活动中心</view>
			</view>
		</view>
		
		<view class="swiper">
			<view class="swiper-tishi">
				<image class="image1-1" src="https://z3.ax1x.com/2021/04/29/gkweoD.png" mode=""></image>
				<text>消息:</text>
				</view>
			<view class="swiper-box">
				<swiper class="swiperbox" autoplay=true circular=true interval=2500 vertical=true>
					<swiper-item class="swiper-item" v-for="item in textdata" :key="item.id">
						<view class="swiper-item">
							<text class="text1-1">{{item.text1}}</text>
							<text class="text1-2">{{item.text2}}</text>
						</view>
					</swiper-item>
				</swiper>
			</view>
		</view>
		
		<view class="image1-2">
			<image class="image1-3" src="https://z3.ax1x.com/2021/04/29/gkBS29.png" mode=""></image>
		</view>
		
		<view class="item1-1-1">
			<view class="item1-2-1">红包兑换</view>
			<view class="item1-3-1">查看规则</view>
		</view>
		
		<view class="item1-1-2">
			<view class="item1-1-3" @tap="delt">-</view>
			<input class="item1-1-5" type="text" value="" v-model="num"/>
			<view class="item1-1-3" @tap="add">+</view>
		</view>
		<view class="integral-all">
			<template v-for="item in integral">
				<view :class="{active:item==defula}" class="integral-item" :key="item" @tap="intege(item)">{{item}}</view>
			</template>
		</view>
		
		<view class="integral-text">我的积分{{userData.integral}}</view>
		
		<view class="congfirm" @tap="exchange">确认兑换</view>
		<view class="look">查看兑换记录</view>
		
	</view>
</template>

<script>
	import {createNamespacedHelpers} from 'vuex'
	const {mapActions,mapState} = createNamespacedHelpers('UserInfor')
	export default {
		data() {
			return {
				num:100,
				defula:'全部',
				integral:['全部','100','500','1000'],
				textdata:[
					{id:1,text1:'842***2852',text2:'获得三亚五日游兑换卷'},
					{id:2,text1:'小小阳',text2:'兑换了 成都一环内别墅一套'},
					{id:3,text1:'752***4563',text2:'兑换了 奔驰梅赛德斯一台'},
					{id:4,text1:'965***752',text2:'兑换了 20元无门槛优惠'},
					{id:5,text1:'741***2852',text2:'兑换了 腾讯视频会员'},
					{id:6,text1:'明75***250',text2:'兑换了 拼多多优惠卷'},
					{id:7,text1:'177***2815',text2:'兑换了 爱奇艺会员卡'},
					{id:8,text1:'155***3882',text2:'兑换了 翼支付话费卷'},
					{id:9,text1:'756***282',text2:'兑换了 洗衣机兑换卡'},
					{id:10,text1:'842***4685',text2:'兑换了 腾讯QQ超级会员'},
				]
			}
		},
		computed:{
			...mapState(['userData','userPass'])
		},
		methods: {
			...mapActions(['exchangemoney','getUser']),
			add(){
				this.num++
			},
			delt(){
				if(this.num>0){
					this.num--
				}
			},
			
			// 事件
			intege(item){
				this.defula=item
				if(item=='全部'){
					this.num=this.userData.integral
				}else if(item=='100'){
					this.num='100'
				}else if(item=='500'){
					this.num='500'
				}else if(item=='1000'){
					this.num='1000'
				}
			},
			
			////兑换余额
			async exchange(){
				const data = await this.exchangemoney({
					username:this.userData.username,
					integral:this.num
				})
				if(data.code==200){
					uni.showToast({
					    title: '兑换成功!',
					    duration: 2000
					},this.getUser({
						username:this.userData.username,
						password:this.userPass
					}));
				}
			}
		}
	}
</script>

<style>
	.sanjiao{
		width: 22rpx;
		height: 22rpx;
	}
	.active{
		background-color: #3476F1;
		color: #FFFFFF;
	}
	.look{
		width: 80%;
		height: 88rpx;
		background-color: #FFFFFF;
		text-align: center;
		color: rgba(0,0,0,0.5);
		margin: 20rpx auto;
		line-height: 88rpx;
		border-radius: 50rpx;
		font-size: 28rpx;
		border: 1rpx solid rgba(0,0,0,0.5);
	}
	.congfirm{
		width: 80%;
		height: 88rpx;
		background-color: #3476F1;
		text-align: center;
		color: #FFFFFF;
		margin: 20rpx auto;
		line-height: 88rpx;
		font-size: 30rpx;
		border-radius: 50rpx;
	}
	.integral-text{
		width: 100%;
		text-align: center;
		color: rgba(0,0,0,0.5);
		font-size: 26rpx;
		margin: 15rpx;
	}
	.integral-all{
		width: 100%;
		height: 70rpx;
		/* border: 1px solid red; */
		display: flex;
	}
	.integral-item{
		width: 100%;
		height: 50rpx;
		text-align: center;
		line-height: 50rpx;
		border: 1rpx solid rgba(0,0,0,0.3);
		border-radius: 50rpx;
		margin: 10rpx 20rpx;
		font-size: 26rpx;
	}
	
	
	.item1-1-1{
		width: auto;
		height: 88rpx;
		/* border: 1px solid red; */
		display: flex;
		justify-content: space-between;
		padding: 0rpx 20rpx;
		line-height: 88rpx;
	}
	.item1-2-1{
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 550;
		color: #333333;
	}
	.item1-3-1{
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #666666;
	}
	
	.item1-1-2{
		width: 600rpx;
		height: 80rpx;
		border-radius: 20rpx;
		border: 1rpx solid rgba(0,0,0,0.3);
		display: flex;
		line-height: 80rpx;
		margin: 20rpx auto 0rpx;
		text-align: center;
		padding: 0rpx 15rpx;
		/* border: 1px solid red; */
	}
	.item1-1-5{
		width: 100%;
		height: 80rpx;
		/* border: 1px solid red; */
		text-align: center;
		color: #007AFF;
	}
	.item1-1-3{
		width:100rpx;
		height: 80rpx;
		/* border: 1px solid red; */
		font-size: 50rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: rgba(0,0,0,0.6);
	}
	
	
	.image1-2{
		width: 95%;
		height: 200rpx;
		border-radius: 20rpx;
		margin: 0rpx auto;
	}
	.image1-3{
		width: 100%;
		height: 200rpx;
	}
	.swiper{
		width: 90%;
		height: 70rpx;
		/* border: 1px solid red; */
		margin: 20rpx auto;
		display: flex;
		box-shadow: 0px 0px 24rpx rgba(0, 0, 0, 0.1);
	}
	.swiper-tishi{
		width: 20%;
		/* border: 1px solid red; */
		text-align: center;
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		line-height: 70rpx;
		color: #666666;
	}
	.swiper-box{
		width: 80%;
		/* border: 1px solid red; */
		line-height: 70rpx;
	}
	.text1-1{
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		line-height: 70rpx;
		color: #3476F1;
	}
	.text1-2{
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		line-height: 70rpx;
	}
	.image1-1{
		width: 26rpx;
		height: 26rpx;
		margin-top: 22rpx;
		margin-right: 10rpx;
	}
	.swiperbox{
		height: 70rpx;
	}
	.top1-1{
		width: 100%;
		height: auto;
		/* border: 1px solid red; */
		padding-top: 100rpx;
		background: linear-gradient(#3476F1,#eeeeee);
	}
	.top{
		background: url('https://z3.ax1x.com/2021/04/22/cOFgKK.png') no-repeat;
		background-size: 100% 130%;
		width: 650rpx;
		height: 200rpx;
		/* border: 1px solid red; */
		margin: 0rpx auto;
		padding: 20rpx;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
	}
/* ///<!-- 用户头像用户名 --> */
	.pres-top-contner {
		width: 100%;
		height: auto;
		/* border: 1rpx solid red; */
		right: 0rpx;
		display: flex;
		margin-top: 15rpx;
	}

	.pers-top-userimage {
		width: 112rpx;
		height: 112rpx;
		/* border: 1rpx solid red; */
		border-radius: 50%;
		background-color: #FFFFFF;

	}
	.userimage {
		width: 112rpx;
		height: 112rpx;
		border-radius: 50%;
	}
	.pers-top-usertext {
		width: 100%;
		height: 112rpx;
		/* border: 1rpx solid red; */

	}
	.pers-username {
		width: auto;
		height: 40rpx;
		font-size: 38rpx;
		font-family: PingFang SC;
		font-weight: bold;
		line-height: 44rpx;
		color: #FFFFFF;
		opacity: 1;
		margin-left: 26rpx;
		/* border: 1rpx solid red; */
	}

	.pers-usertext {
		width: auto;
		height: 35rpx;
		/* border:  1rpx solid red; */
		margin-left: 26rpx;
		display: flex;
		margin-top: 25rpx;
	}

	.pers-cond {
		padding: 0rpx 15rpx;
		background: linear-gradient(90deg,#FF0000,#FF7F00,#FFFF00,#00FF00,#FF0000,#00FFFF);
		color: #000000;
		border-radius: 40rpx;
		text-align: center;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 900;
	}

	.jifen{
		color: #FFFFFF;
		font-size: 32rpx;
		padding-left: 20rpx;
		margin-top: 15rpx;
	}


.exclusive-item {
		width: 100%;
		height: 184rpx;
		background: #EEEEEE;
		box-shadow: 0px 0px 24rpx rgba(0, 0, 0, 0.05);
		margin: 0rpx auto;
		display: flex;
		flex-grow: 1;
	}

	.item-box {
		width: 100%;
		height: 154rpx;
		/* border: 1px solid red; */
		padding-top: 30rpx;
		text-align: center;
		position: relative;
	}
	.item-image {
		width: 60rpx;
		height: 60rpx;
	}
	.item-text {
		text-align: center;
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 400;
		line-height: 34rpx;
		color: #666666;
	}
</style>
